package Ep09_DynamicProgram.DP9_0096;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/7/7 19:35
 * 说明：搜索不同的二叉树
 */

public class Mine {
    public int numTrees(int n) {
        if (n <= 2) return n;
        int[] dp = new int[n+1];
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 3; i <= n; ++i) {
            for (int j = 1; j <= i; ++j) {
                dp[i] += dp[j-1] * dp[i-j];
            }
        }
        return dp[n];
    }
}
